package com.example.demo5.info.controller;

import com.example.demo5.info.mapper.MenuMapper;
import com.example.demo5.info.pojo.Menu;
import com.example.demo5.info.service.MenuService;
import com.example.demo5.result.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuMapper menuMapper;
    @Resource
    private MenuService menuService;
   //查看所有列表
    @GetMapping("/list")
    public AjaxResult getList(Menu menu){
        return menuService.getList(menu);
    };
    //  新增菜单
    @PostMapping("/add")
    public AjaxResult setList(@RequestBody Menu menu){
        return menuService.setList(menu);
    };

    // 删除列表
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable long id) {
        return menuService.delete(id);
    }
    //修改列表
    @PostMapping("/put")
    public  AjaxResult putList(@RequestBody Menu menu){
        return  menuService.modify(menu);
    }
    //查询某一条数据
    @GetMapping("lsit/id")
    public AjaxResult queryId(Menu menu){
        return  menuService.queryId(menu);
    }

}
;

